#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2024/7/8 15:41
# @Author  : 王凯
# @File    : boss_demo.py
# @Project : scrapy_spider
import parsel
import requests

from utils.proxies_tools import get_company_ip_crawler_by_api

session = requests.Session()
session.proxies = get_company_ip_crawler_by_api()
print(session.proxies)
headers = {
    # "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
    # "Accept-Language": "zh-CN,zh;q=0.9,zu;q=0.8,be;q=0.7,en;q=0.6",
    # "Cache-Control": "no-cache",
    # "Connection": "keep-alive",
    # "Pragma": "no-cache",
    # "Sec-Fetch-Dest": "document",
    # "Sec-Fetch-Mode": "navigate",
    # "Sec-Fetch-Site": "none",
    # "Sec-Fetch-User": "?1",
    # "Upgrade-Insecure-Requests": "1",
    # "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1"
    # "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36",

    # "accept": "application/json, text/plain, */*",
    # "accept-language": "zh-CN,zh;q=0.9,zu;q=0.8,be;q=0.7,en;q=0.6",
    # "cache-control": "no-cache",
    # "pragma": "no-cache",
    # "priority": "u=1, i",
    # "referer": "https://www.zhipin.com/web/geek/job?query=%E5%90%88%E8%82%A5%E5%8D%93%E5%90%8C%E6%95%99%E8%82%B2%E5%92%A8%E8%AF%A2%E6%9C%89%E9%99%90%E5%85%AC%E5%8F%B8&city=101210100",
    # "sec-ch-ua": "\"Chromium\";v=\"124\", \"Google Chrome\";v=\"124\", \"Not-A.Brand\";v=\"99\"",
    # "sec-ch-ua-mobile": "?0",
    # "sec-ch-ua-platform": "\"Windows\"",
    # "sec-fetch-dest": "empty",
    # "sec-fetch-mode": "cors",
    # "sec-fetch-site": "same-origin",
    # "token": "0Gpb6XqU6htb5wOh",
    # "traceid": "5270A75B-84B9-4EBE-AC64-66DCEBE0A389",
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36",
    # "x-requested-with": "XMLHttpRequest",
    # "zp_token": "V1R9wiGeX12ltqVtRuzR0cISK27zPWxSQ~"

}
# headers = {
#     "accept": "application/json, text/plain, */*",
#     "accept-language": "zh-CN,zh;q=0.9,zu;q=0.8,be;q=0.7,en;q=0.6",
#     "cache-control": "no-cache",
#     "content-type": "application/x-www-form-urlencoded;charset=utf-8",
#     "href": "https://www.kanzhun.com/",
#     "pragma": "no-cache",
#     "priority": "u=1, i",
#     "referer": "https://www.kanzhun.com/",
#     "reqsource": "fe",
#     "sec-ch-ua": "\"Chromium\";v=\"124\", \"Google Chrome\";v=\"124\", \"Not-A.Brand\";v=\"99\"",
#     "sec-ch-ua-mobile": "?0",
#     "sec-ch-ua-platform": "\"Windows\"",
#     "sec-fetch-dest": "empty",
#     "sec-fetch-mode": "cors",
#     "sec-fetch-site": "same-origin",
#     # "traceid": "98ac6917-e1d0-43f5-8f76-4bfaab5012bf",
#     "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36",
#     "x-requested-with": "XMLHttpRequest"
# }
cookies = {
    # "__c": "1720489616",
    # "R_S_IDS": "//www.baidu.com/",
    # "wd_guid": "4c4a56ef-521e-4b06-9901-685f0343254a",
    # # "__g": "-",
    # # "historyState": "state",
    # # "Hm_lvt_1f6f005d03f3c4d854faec87a0bee48e": "1720489618",
    # "HMACCOUNT": "DEE49CDB006C27E1",
    # # "arp_scroll_position": "0",
    # "__l": "r=https%3A%2F%2Fwww.baidu.com%2Flink%3Furl%3Daa1ehUuBE0GcmyYie2IfmTBHF8c7KCgFi2eDYaF0BniLNlVS3gRdnWeSs-lHs03p%26wd%3D%26eqid%3Da4aed87e0095412e00000004668c968e&l=%2Fapi_to%2Fhome%2Frec.json%3Fb%3Dwc8hJxYZDTp46Zh_yQ8xtw~~%26kiv%3DwX0JqPE1zOqXiwZF",
    # "__a": "14597212.1720489616..1720489616.2.1.2.2",
    # "Hm_lpvt_1f6f005d03f3c4d854faec87a0bee48e": "1720489626"
}
# url = "https://m.zhipin.com/wapi/zpgeek/mobile/search/joblist.json"
# params = {
#     "query": "杭州微风企科技有限公司",
#     "page": "1",
#     "city": "101210100"
# }
url = "https://m.zhipin.com/job_detail/e31674d7d07e043a1XF929m5EVVT.html"
url = "https://www.zhipin.com/job_detail/7e9719e103e2f0c71XFz3tW7E1tY.html"
url = "https://www.zhipin.com/job_detail/15087a1e33fd92361nJy2Ni8EFpW.html"
url = "https://m.zhipin.com/gongsi/job/e6f62cd5f99a1ac71XZ_3tm9Eg~~.html"
# url = "https://m.zhipin.com/wapi/zpgeek/brand/job/querylist.json?brandId=e6f62cd5f99a1ac71XZ_3tm9Eg~~&page=1&pageSize=15&positionLv1=&city=&experience=&salary="
url = "https://www.zhipin.com/wapi/zpgeek/job/detail.json?securityId=XzFZjlVbkE1pT-41LFYQ0a5ufitMpAK8mdA0LnVtmmaqsChPsY1e2751swptJS0PUIiIJE1zWcw2AlOjRFP0FmzlkpSfQFQQxg9atOCwHYyq4qOT-6eVOOw~&lid=37ecNdiI1xV.search.16"
# url = "https://www.zhipin.com/wapi/zpgeek/search/joblist.json?scene=1&query=%E5%90%88%E8%82%A5%E5%8D%93%E5%90%8C%E6%95%99%E8%82%B2%E5%92%A8%E8%AF%A2%E6%9C%89%E9%99%90%E5%85%AC%E5%8F%B8&city=101210100&experience=&payType=&partTime=&degree=&industry=&scale=&stage=&position=&jobType=&salary=&multiBusinessDistrict=&multiSubway=&page=1&pageSize=30"
# session.get('https://www.kanzhun.com/', headers=headers)
# url = "https://www.kanzhun.com/api/search/autoComplete_v3.json?query=合肥卓同教育咨询有限公司"
# url = "https://www.kanzhun.com/firm/info/1nJ53NS_EVY~.html"
# url = "https://m.zhipin.com/gongsi/job/e6f62cd5f99a1ac71XZ_3tm9Eg~~.html?ka=job-detail-company_custompage"
# url = "https://www.zhipin.com/wapi/zpboss/h5/pc/brandInfo/taste/getTasteInfo?encryptBrandId=e6f62cd5f99a1ac71XZ_3tm9Eg~~&page=1&pageSize=10"
# url = "https://www.zhipin.com/gongsi/e6f62cd5f99a1ac71XZ_3tm9Eg~~.html?ka=company-intro"
response = session.get(url, headers=headers, cookies=cookies, allow_redirects=False)

print(response)
print(response.text)
# res = response.json()
# print(res.get("code"))
# print(res.get("zpData").get("html"))
# if res.get("code") == 0:
#     response = parsel.Selector(res.get("zpData").get("html"))
#     print()
